﻿using SqlSugar;
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Magic.Core.Service;

#region 输入参数
public class AddSysMenuInput
{
    /// <summary>
    /// 菜单类型（字典 0目录 1菜单 2按钮）
    /// </summary>
    [Required(ErrorMessage = "菜单类型不能为空")]
    public string Type { get; set; }

    /// <summary>
    /// 父Id
    /// </summary>
    public long Pid { get; set; }

    /// <summary>
    /// 名称
    /// </summary>
    public string Name { get; set; }

    /// <summary>
    /// 编码
    /// </summary>
    public string Code { get; set; }

    /// <summary>
    /// 图标
    /// </summary>
    public string Icon { get; set; }

    /// <summary>
    /// 路由地址
    /// </summary>
    public string Router { get; set; }

    /// <summary>
    /// 组件地址
    /// </summary>
    public string Component { get; set; }

    /// <summary>
    /// 权限标识
    /// </summary>
    public string Permission { get; set; }

    /// <summary>
    /// 应用分类（应用编码）
    /// </summary>
    public string Application { get; set; }

    /// <summary>
    /// 打开方式（字典 0无 1组件 2内链 3外链）
    /// </summary>
    public string OpenType { get; set; }

    /// <summary>
    /// 是否可见（Y-是，N-否）
    /// </summary>
    public string Visible { get; set; }

    /// <summary>
    /// 内链地址
    /// </summary>
    public string Link { get; set; }

    /// <summary>
    /// 重定向地址
    /// </summary>
    public string Redirect { get; set; }

    /// <summary>
    /// 权重（字典 1系统权重 2业务权重）
    /// </summary>
    public string Weight { get; set; }

    /// <summary>
    /// 排序
    /// </summary>
    public int Sort { get; set; }

    /// <summary>
    /// 备注
    /// </summary>
    public string Remark { get; set; }

    /// <summary>
    /// 多标签模式下是否开启缓存，默认开启
    /// </summary>
    public bool KeepAlive { get; set; } = true;
}

public class EditSysMenuInput : AddSysMenuInput
{
    /// <summary>
    /// 菜单Id
    /// </summary>
    [Required(ErrorMessage = "菜单Id不能为空")]
    public long Id { get; set; }

    /// <summary>
    /// 父Id
    /// </summary>DeleteMenuInput
    [Required(ErrorMessage = "父级菜单Id不能为空")]
    public long Pid { get; set; }
}


public class QueryMenuListInput
{
    /// <summary>
    /// 应用分类（应用编码）
    /// </summary>
    public string Application { get; set; }

    /// <summary>
    /// 应用分类（应用编码）
    /// </summary>
    public string Name { get; set; }
}

public class QueryMenuTreeInput
{
    /// <summary>
    /// 应用分类（应用编码）
    /// </summary>
    public string Application { get; set; }
}

public class ChangeAppMenuInput
{
    /// <summary>
    /// 应用编码
    /// </summary>DeleteMenuInput
    [Required(ErrorMessage = "应用编码不能为空")]
    public string Application { get; set; }
}

#endregion

#region 输出参数
/// <summary>
/// 菜单树（列表形式）
/// </summary>
public class MenuOutput : ITreeNode
{
    /// <summary>
    /// 菜单Id
    /// </summary>
    public long Id { get; set; }

    /// <summary>
    /// 子节点
    /// </summary>
    public List<MenuOutput> Children { get; set; } = new List<MenuOutput>();

    public long GetId()
    {
        return Id;
    }

    public long GetPid()
    {
        return Pid;
    }

    public void SetChildren(IList children)
    {
        Children = (List<MenuOutput>)children;
    }

    /// <summary>
    /// 父Id
    /// </summary>
    public long Pid { get; set; }

    /// <summary>
    /// 名称
    /// </summary>
    public string Name { get; set; }

    /// <summary>
    /// 编码
    /// </summary>
    public string Code { get; set; }

    /// <summary>
    /// 菜单类型（字典 0目录 1菜单 2按钮）
    /// </summary>
    public string Type { get; set; }

    /// <summary>
    /// 图标
    /// </summary>
    public string Icon { get; set; }

    /// <summary>
    /// 路由地址
    /// </summary>
    public string Router { get; set; }

    /// <summary>
    /// 组件地址
    /// </summary>
    public string Component { get; set; }

    /// <summary>
    /// 权限标识
    /// </summary>
    public string Permission { get; set; }

    /// <summary>
    /// 应用分类（应用编码）
    /// </summary>
    public string Application { get; set; }

    /// <summary>
    /// 打开方式（字典 0无 1组件 2内链 3外链）
    /// </summary>
    public string OpenType { get; set; }

    /// <summary>
    /// 是否可见（Y-是，N-否）
    /// </summary>
    public string Visible { get; set; }

    /// <summary>
    /// 内链地址
    /// </summary>
    public string Link { get; set; }

    /// <summary>
    /// 重定向地址
    /// </summary>
    public string Redirect { get; set; }

    /// <summary>
    /// 权重（字典 1系统权重 2业务权重）
    /// </summary>
    public string Weight { get; set; }

    /// <summary>
    /// 排序
    /// </summary>
    public int Sort { get; set; }

    /// <summary>
    /// 备注
    /// </summary>
    public string Remark { get; set; }

    /// <summary>
    /// 多标签模式下是否开启缓存，默认开启
    /// </summary>
    public bool KeepAlive { get; set; } = true;
}
#endregion